import {
  Toast
} from 'vant'
import { PROJECT_BASE_URL } from '@/libs/config'
import Fly from 'flyio/dist/npm/fly'
const fly = new Fly()

fly.interceptors.request.use(request => {
  request.withCredentials = true
  return request
})

fly.interceptors.response.use(
  response => {
    // 只将请求结果的data字段返回
    // console.log(response)
    return response.data
  },
  err => {
    // 发生网络错误后会走到这里
    console.log('err', err)
    Toast('微信签名获取失败')

    return err
  }
)

const API_WECHAT_SIGN = (data) => fly.get(PROJECT_BASE_URL + '/pub/transfer', data)

export { API_WECHAT_SIGN }
